Imports Microsoft.VisualBasic

Public Class DivisionManager
    Public Function GetAllDivision() As DataTable
        Dim dat As New clsData
        Dim sql As New StringBuilder

        sql.AppendFormat(" SELECT DISTINCT c.Division FROM ChannelView c ")
        sql.AppendFormat(" join RoleChannelMapping rcm ")
        sql.AppendFormat(" on c.Division=rcm.Division and c.Signature=rcm.Signature ")
        sql.AppendFormat(" and c.Channel=rcm.Channel ")
        sql.AppendFormat(" join RoleUserMapping ru on rcm.RoleID =ru.RoleID ")
        sql.AppendFormat(" and ru.UserID='{0}' ", clsAuth.GetUserID())
        sql.AppendFormat(" order by c.Division")

        Return dat.GetData(sql.ToString())
    End Function

    Public Function GetDivisions() As List(Of String)
        Dim dt As DataTable = GetAllDivision()
        Dim list As New List(Of String)

        For Each dr As DataRow In dt.Rows
            list.Add(dr("Division"))
        Next

        Return list
    End Function
End Class
